/*
*作者---杨彬
*
*/
<template>
    <div>
      <header>
      <img src="./../../assets/index/logo.png" class="com-div-middle-ab program-left">
        <input class="com-div-center-center-ab" placeholder="请输入商品名称"  v-model="productName">
        <img src="./../../assets/index/searcher.png" class="com-div-middle-ab program-right"
          @click="getData(productName)"
        >
      </header>
      <section>
        <div class="index-product-list" v-for="pindex in arr1">
        <div class="div-list">
          <div class="com-font0 list-header"><img src="./../../assets/index/newProduct.png"></div>
          <div class="list-content">
            <div class="list-item" v-for="(oitem,oindex) in newData"  @click="goProducDetailFn(oitem)">
              <div class="item-picture">
                <img :src="oitem.img">
              </div>
              <p class="en-name" v-text="oitem.englishName">

              </p>
              <p class="cn-name" v-text="oitem.name">

              </p>
              <p class="price-size" v-text="oitem.productSpecifications[0].price+'元/'+oitem.productSpecifications[0].name+oitem.productUnit">

              </p>
            </div>
            <div class="com-clear-float"></div>
          </div>
        </div>
        </div>
      </section>
      <cake-foot :sData="sData"></cake-foot>
    </div>
</template>
<script type="text/javascript">
  import cakeFoot from "src/components/com/footer/footer.vue"
  export default {
    data(){
      return{
        arr1:[1],
        newData:"",
        productName:""
      }
    },
    props:["sData"],
    components:{
      cakeFoot
    },
    methods:{
      getData(oname){
        this.getAjax(this.sData.url.newProduct,
          {isNew:"",productName:this.productName},
          (res)=>{
            if(res&&res.data){
              console.log(res.data);
              this.newData=res.data;
              //console.log(this.newData[0].productSpecifications[0].price);
            }else{
              m$.template({
              val: '很抱歉,没有符合条件的商品',
              time: 1500
            })
          }    
        })
      },
      goProducDetailFn(oitem){
        this.$router.push({
          name:'productDetail',
          params:{productId:oitem.id}
        })
      }
    },
    created(){
      document.title=this.sData.indexStaticsData.title;
      this.getData();
    }
  }

</script>
<style scoped lang="less">
  @import "newProduct.less";
</style>
